"use strict";
{
    //泛型函数
    //声明函数    T 为泛型参数 T  P  V A B C  a b c 均可
    function createArray(count, value) {
        //声明数组
        let arr = [];
        //循环
        for (let i = 0; i < count; i++) {
            arr.push(value);
        }
        //返回结果
        return arr;
    }
    //调用
    // let arr = createArray<string>(3, 'love');
    //运行
    // arr[0].toFixed(2);
    // arr[0].toFixed(2);
}
{
    //多个泛型参数的演示   []
    function createArray(one, two) {
        return [one, two];
    }
    let res = createArray("123", 456);
    // res[1].
    // axios.get   .post  .put  .patch  .delete  都是泛型函数
}
{
    //泛型接口
    let response = {
        status: 200,
        headers: {
            a: 100,
            b: 200,
        },
        data: {
            id: 2,
            name: "张三",
            age: 18,
        },
    };
    let response2 = {
        status: 200,
        headers: {},
        data: {
            id: 2,
            title: "红楼梦",
            price: 20,
        },
    };
    let arr = ["a", "b", "c"];
}
{
    //泛型接口
    let response = {
        status: 200,
        headers: {
            a: 100,
            b: 200,
        },
        data: {
            code: "000",
            msg: "ok",
            data: {
                id: 2,
                name: "张三",
                age: 18,
            },
        },
    };
    let response2 = {
        status: 200,
        headers: {
            a: 100,
            b: 200,
        },
        data: {
            code: "000",
            msg: "ok",
            data: {
                id: 2,
                title: "三国演义",
                price: 18.8
            },
        },
    };
}
{
    //泛型类
    class Container {
        //构造方法
        constructor(arr) {
            this.store = arr;
        }
        push(v) {
            this.store.push(v);
        }
    }
    //实例化
    // let container = new Container<string>(['西游记','红楼梦','三国演义','水浒传']);
    // container.push('三体');
    let container = new Container([]);
    container.push({
        id: 1,
        title: '西游记',
        price: 15.8
    });
    container.push({
        id: 2,
        title: '红楼梦',
        price: 15.9
    });
    console.log(container);
}
{
    function fn(arg) {
        console.log(arg.length);
    }
    fn('abc');
    fn([1, 2, 3]);
    // fn(123);
}
